<template>
    <div>
        <Form :label-width="100" inline>
            <Form-item label="推送状态">
<!--                <dictSelect :sel_val='queryParam.success_or_not' dictCode="mpld0001" :bindData.sync="queryParam.mpld0001"-->
<!--                            style="width: 200px"/>-->
                <Select v-model="queryParam.success_or_not" style="width: 150px">
                    <Option value="0">其他异常</Option>
                    <Option value="1">在保状态异常</Option>
                    <Option value="2">救助类型异常</Option>
                </Select>
            </Form-item>
            <Form-item label="姓名">
                <Input v-model="queryParam.name" placeholder="请输入姓名" style="width: 200px"/>
            </Form-item>
            <Form-item label="证件号码">
                <Input v-model="queryParam.cardno" placeholder="请输入证件号码" style="width: 200px"/>
            </Form-item>
            <Row class="button_row">
                <span style="float: left;">
                    <Button type="primary" @click="pushAllAbnormalData">一键推送异常数据</Button>
                </span>
                <span style="float: right;">
                 <Button type="primary" @click="searchQuery">查询</Button>
                 <Button type="primary" class="button_item_left" @click="searchReset">重置</Button>
                </span>
            </Row>
        </Form>

        <div class="table_div">
            <Table :columns="columns" :data="tableData" :loading="Loading">
                <!--<template slot-scope="{ row, index  }" slot="action">-->
                <!--</template>-->
            </Table>
            <Page :total="dataCount" :page-size="pageSize" show-total class="paging"
                  @on-change="handleTableChange" :current="pageNo"></Page>
        </div>
<!--        <Modal v-model="detailModal" title="推送详细信息" width="1000" style="position:relative;">-->
<!--            <div >-->
<!--                <Table :columns="detailColumns" :data="detailInfoData" :loading="Loading">-->
<!--                </Table>-->
<!--                <Page :total="dataCountDetail" :page-size="pageSize"  class="paging"-->
<!--                      @on-change="handleTableChangeV"></Page>-->
<!--            </div>-->
<!--            <div slot="footer">-->
<!--&lt;!&ndash;                <Button type="text" size="large" @click="detailModal = false">关闭</Button>&ndash;&gt;-->
<!--               <br />-->
<!--            </div>-->
<!--        </Modal>-->
    </div>
</template>

<script>
    import {postAction} from '@/api/request'
    import {CommonMixin} from '@/views/common/js/CommonMixin'
    import dictSelect from '@/components/dictSelect/dictSelect.vue'
    import DateFormat from '@/plugins/format.js'

    export default {
        mixins: [CommonMixin],
        components: {
            // dictSelect
        },
        data() {
            return {
                rules: {
                    cfab0001: [
                        {required: true, message: '信息必填', trigger: 'blur'}
                    ],
                    cfab0002: [
                        {required: true, message: '信息必填', trigger: 'blur'}
                    ],
                    cfab0003: [
                        {required: true, message: '必须是数字类型', trigger: 'blur', type: 'number'}
                    ],
                    cfab0004: [
                        {required: true, message: '必须是数字类型', trigger: 'blur', type: 'number'}
                    ],
                    cfab0005: [
                        {required: true, message: '信息必填', trigger: 'blur', type: 'date'},
                    ],
                    cfab0006: [
                        {required: true, message: '信息必填', trigger: 'blur', type: 'date'},
                    ]
                },
                columns: [
                    {
                        title: '推送日期',
                        key: 'handle_date'
                    },
                    {
                        title: '申请人姓名',
                        key: 'name'
                    },
                    {
                        title: '申请人身份证号',
                        key: 'cardno'
                    },
                    {
                        title: '救助类型',
                        key: 'rescue_type'
                    },
                    {
                        title: '推送状态',
                        key: 'success_or_not',
                        render: (h,params) => {
                            console.log("推送状态是: ",params.row.success_or_not)
                            let result = params.row.success_or_not
                            console.log(typeof(result))
                            if (result === '1'){
                                return h('div','在保状态异常')
                            }else if (result === '2'){
                                return h('div','保障类型异常')
                            }else{
                                return h('div','其他异常')
                            }
                        }
                    }
                ],
                // detailColumns: [
                //     {
                //         title: '身份证号',
                //         key: 'mpps0008',
                //         align: 'center',
                //         width: '160px',
                //     },
                //     {
                //         title: '姓名',
                //         key: 'mpps0009',
                //         align: 'center',
                //         width: '100px',
                //     },
                //     {
                //         title: '保障标识',
                //         key: 'mpps0010',
                //         width: '150px',
                //         align: 'center'
                //     },
                //     {
                //         title: '操作内容',
                //         key: 'mpps0011',
                //         align: 'center'
                //     },
                // ],
                tableData: [],
                dataParamDetail:{},
                detailModal: false,
                // detailInfoData: [],
                // dataCountDetail: 0,
                Loading: false,
                url: {
                    list: "/api/ac/subsistence/fwglService/getPageList",
                    detailList: "/api/ac/subsistence/fwglService/getDetailPageList"
                },
                formData: {
                    cfab0001: '',
                    cfab0002: '',
                    cfab0003: '',
                    cfab0004: '',
                    cfab0005: '',
                    cfab0006: '',
                    cfab0009: '',
                    cfab0010: ''
                },
                queryParam: {},
                visible: false,
                showSubmit: true,
                dataCount: 0,
                pageSize: 10,
                modal: false,
                title: ""
            }
        },
        methods: {
            handleTableChangeV(index) {
                let that = this;
                let url = that.url.detailList
                var dataParam = {
                    pageNo : index,
                    mpps0007: that.dataParamDetail.mpps0007,
                    mpps0099: that.dataParamDetail.mpps0099
                }
                postAction(url, dataParam).then((res) => {
                    if (res.data.errcode != 0) {
                        that.$Message.error(res.data.errmsg);
                    } else {
                        that.detailInfo = true;
                        // that.detailInfoData = res.data.data.results;
                        // that.dataCountDetail = res.data.data.totalRecord;
                    }
                }).finally(() => {
                    that.Loading = false;
                });
            },
            handleDetail(row, type) {
                let that = this;
                // that.detailInfoData = [];
                // that.dataCountDetail = 0;
                that.detailModal = true;
                let mpps0007 = type;
                let mpps0099 = row.id;
                let url = that.url.detailList
                that.dataParamDetail = {mpps0007: mpps0007, mpps0099: mpps0099}
                postAction(url, that.dataParamDetail).then((res) => {
                    if (res.data.errcode != 0) {
                        that.$Message.error(res.data.errmsg);
                    } else {
                        that.detailInfo = true;
                        // that.detailInfoData = res.data.data.results;
                        // that.dataCountDetail = res.data.data.totalRecord;
                    }
                }).finally(() => {
                    that.Loading = false;
                });
            },
            // 一键推送全部异常数据
            pushAllAbnormalData(){
                postAction("/api/ac/subsistence/fwglService/createPushAllAbnormalData", {}).then((res) => {
                    if (res.data.errcode != 0) {
                        that.$Message.error(res.data.errmsg);
                    } else {
                        that.$Message.success(res.data.data);
                    }
                }).finally(() => {
                    // that.Loading = false;
                    that.loadData();
                });
            }
        },
        created() {
            this.loadData();
        },
    }
</script>
<style scoped>
    .paging {
        float: right;
        margin-top: 10px;
    }

    /deep/ .ivu-upload-list {
        display: none;
    }
</style>
